// productAttribute  商品属性  相关请求 API
import http from './request';


// 1. 【商品属性分类管理】 相关请求API

// 分页获取所有商品属性分类    // productAttribute/category/list
const getAttributeList = (params: IAttributeListParams): PRES<IProductAttributeModel> => http.get(`productAttribute/category/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}`);


// 添加商品属性分类   // productAttribute/category/create
const addAttributeCategory = (name: string): PRES<number> => http.post(`productAttribute/category/create?name=${name}`);


// 修改商品属性分类    // productAttribute/category/update/{id}
const updateAttributeCategory = (id: number, name: string): PRES<number> => http.post(`productAttribute/category/update/${id}?name=${name}`);


// 删除单个商品属性分类    // productAttribute/category/delete/{id}
const deleteAttributeCategory = (id: number): PRES<number> => http.get(`productAttribute/category/delete/${id}`);





// 2. 【商品属性管理】  相关请求API

// 根据分类查询属性列表或参数列表  // productAttribute/list/{cid}
const getAttrListByType = (params: IAttrListByTypeParams): PRES<IGetAttrListModel> => http.get(`productAttribute/list/${params.cid}`, { params });


// 批量删除商品属性   // productAttribute/delete
const deleteProductAttribute = (ids: number[]): PRES<number> => http.post(`productAttribute/delete?ids=${ids}`);




// 导出
export {
  getAttributeList,
  addAttributeCategory,
  updateAttributeCategory,
  deleteAttributeCategory,
  getAttrListByType,
  deleteProductAttribute,
}